package org.jivesoftware.smackx.provider;

import java.util.HashMap;
import java.util.Map;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.xmlpull.v1.XmlPullParser;

public class PEPProvider
  implements PacketExtensionProvider
{
  Map<String, PacketExtensionProvider> nodeParsers = new HashMap();
  PacketExtension pepItem;

  public PacketExtension parseExtension(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    int i = 0;
    while (true)
    {
      int j;
      label99: 
      do
        while (true)
        {
          PacketExtensionProvider localPacketExtensionProvider;
          do
          {
            do
            {
              if (i != 0)
                return this.pepItem;
              j = paramXmlPullParser.next();
              if (j != 2)
                break label99;
            }
            while ((paramXmlPullParser.getName().equals("event")) || (!(paramXmlPullParser.getName().equals("items"))));
            String str = paramXmlPullParser.getAttributeValue("", "node");
            localPacketExtensionProvider = (PacketExtensionProvider)this.nodeParsers.get(str);
          }
          while (localPacketExtensionProvider == null);
          this.pepItem = localPacketExtensionProvider.parseExtension(paramXmlPullParser);
        }
      while ((j != 3) || (!(paramXmlPullParser.getName().equals("event"))));
      i = 1;
    }
  }

  public void registerPEPParserExtension(String paramString, PacketExtensionProvider paramPacketExtensionProvider)
  {
    this.nodeParsers.put(paramString, paramPacketExtensionProvider);
  }
}